<template>
  <div class="mypublic-container">
    <van-nav-bar left-text="我的" left-arrow @click-left="this.$router.go(-1)" />
    <div class="content">
      <div class="card" v-for="item in publiclist" :key="item.id">
        <div class="left">
          <img :src="item.nice.pic ? 'http://192.168.101.65:9000' + item.nice.pic : pic" alt="" />
        </div>
        <div class="right">
          <p class="name">{{ item.nice.name }}</p>
          <p class="price">{{item.nice.point }}积分</p>
          <img src="../../assets/image/jiangpai.png" alt="" class="finished" v-if="item.status === '1'">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { showToast } from 'vant'
import { getMyPublic } from '../../api/user.js'
export default {
  data() {
    return {
      pic: require('../../assets/image/default.png'),
      publiclist: []
    }
  },
  created() {
    this.getMyPublic()
  },
  methods: {
    async getMyPublic() {
      const { data: res } = await getMyPublic()
      if (res.code === 1) {
        this.publiclist = res.data
      } else {
        showToast('数据获取失败！')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.mypublic-container {
  height: 100vh;
  background-color: #f3f3f3;
  // 导航
  .van-nav-bar {
    background-color: #55c24d;
    :deep(.van-icon) {
      color: #fff;
    }
    :deep(.van-nav-bar__text) {
      color: #fff;
      font-size: 16px;
      font-weight: 500;
    }
  }

  .content {
    padding: 20px;
    .card {
      display: flex;
      height: 100px;
      background-color: #fff;
      margin-bottom: 16px;
      border-radius: 8px;
      box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.2);

      .left {
        width: 45%;
        height: 100%;
        box-sizing: border-box;
        border-radius: 8px;
        overflow: hidden;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .right {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        margin-left: 10px;

        p {
          margin: 0;
        }

        .name {
          font-size: 16px;
          font-weight: 600;
        }

        .finished {
          position: absolute;
          bottom: 0;
          right: 0;
          width: 45px;
          height: 45px;
        }
      }
    }
  }
}
</style>
